home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
001
/
log_user.arc
/
LOG_USER.BAT
Wrap
DOS Batch File
|
1986-09-17
|
6KB
|
153 lines
rem This program is used to permit local area network administrators
rem to restrict access to single-user software programs in accordance
rem with the number of licenses that have been purchased.
rem
rem The example below is set up to give three users access to one
rem copy of LOTUS 1-2-3 (tm) and prevent any further access until
rem one of the three exit LOTUS.
rem
rem You must rename this program with the name you would usually
rem use to call the software and rename the software itself to
rem something else. In our example, this file would be named
rem LOTUS.BAT, and we have to rename LOTUS itself to L123.COM.
rem So you will notice that our program call used below (for purpose
rem of example) is L123.
rem
rem No directory changes are shown in this example, but you must be
rem very careful to always be in the same directory when the user
rem enters and exits the program. So, for example, if I have Lotus
rem in my \LOTUS subdirectory and this file (LOG_USER.BAT) in the
rem root directory, I would have to change to my /LOTUS directory
rem before calling Lotus, and change back to the root directory
rem after exiting Lotus. You can see how un-necessarily complex this
rem is. You will always be better off keeping this program in the
rem same directory as the software that is being protected IF YOU
rem CAN. Not all software returns you to the directory you started
rem the program from! This is especially true of programs like
rem SMART that allow you to establish "data paths" to
rem keep the programs separate from the data files.
rem
rem IF LOG_USER EVER FAILS TO WORK, IT IS PROBABLY BECAUSE YOU ARE
rem NOT PUTTING THE USER IN THE PROPER DIRECTORY TO CREATE AND
rem DELETE THE USER?.LOG FILES.
rem
rem PROGRAM: LOG_USER
rem Do not display commands
rem
echo off
rem
rem Check for active users, starting with largest number possible.
rem
if exist USER3.LOG goto NOT_AVAIL
if exist USER2.LOG goto LAST_ONE
if exist USER1.LOG goto SECOND_USER
rem
rem If the person attempting to log on gets this far, then he or she
rem Is the first user so we write a dummy file (which may contain
rem Anything--we just need the file name to be in the directory) and
rem Then let them into the software. XXX is a dummy file containing
rem One character. It is used for copying. The copy command would
rem Normally issue the message "1 File(s) Copied" but we suppress this
rem By redirecting it to the NUL device as shown.
rem
copy XXX USER1.LOG >nul:
rem
rem Then we call the program...
rem
L123
rem
rem After the user exits the program, we have to erase a dummy
rem file so we use the procedure CLEAR_USER
rem
goto CLEAR_USER
rem
rem Now we must check for cases where the user was not the first
rem one to log onto the software.
rem
rem If one user is already on, we must set a second user log file
rem in the directory and be ready to erase a dummy file when the second
rem user exits.
rem
:SECOND_USER
copy XXX USER2.LOG >nul:
L123
goto CLEAR_USER
rem
rem If two users are already on, we must set a third user
rem log file in the directory and be ready to erase a dummy file when
rem the third user exits.
rem
:LAST_ONE
copy XXX USSER3.LOG >nul:
L123
goto CLEAR_USER
rem
rem If all three users are already logged on, then we gently inform
rem this user that he cannot access the software right now.
rem
:NOT_AVAIL
cls
echo All Available Copies Of LOTUS 1-2-3 Are In Use.
echo Please Try Again Later.
pause
goto END
rem
rem Now, as these users log off of LOTUS, we must be ready to let
rem other users on, so we clear the log files we have been
rem creating as they logged on. We do this in reverse order, so
rem the largest numbered log file is deleted first. This means that
rem the log files correctly represent the number of users logged
rem on regardless of the order they logged on and off.
rem
:CLEAR_USER
if exist USER3.LOG goto ONE_FREE
if exist USER2.LOG goto TWO_FREE
rem
rem If the user has gotten this far, then he is the only one logged
rem on, and we only need to delete the last log file. As we did
rem with the copy command, we redirect the output to the NUL device.
rem
del USER1.LOG >nul:
goto END
rem
rem If all three users were logged on, we need to delete the last log
rem file and then exit.
rem
:ONE_FREE
del USER3.LOG >nul:
goto END
rem
rem If Two users were logged on, we need to delete the middle user
rem log file and then exit.
rem
:TWO_FREE
del USER2.LOG >nul:
rem
rem Now we can return to DOS.
rem
:END
cls
echo Returning to DOS...
rem
rem Problems can crop up in two different cases when using this
rem system. If the user types Ctrl-Break while the batch file is
rem executing, or if he resets his PC after having entered the
rem protected software, some log files can be left hanging open
rem when no one is actually on the software. For this reason, the
rem AUTOEXEC.BAT file on the server should contain the command
rem
rem del USER?.LOG >nul:
rem
rem to make sure all log files are cleared during a network reset.
rem
rem Don Merz
rem Blue Cross of Western Pennsylvania
rem 1 Smithfield Street
rem Pittsburgh, Pa. 15222
rem (412) 255 - 7444